<?php $count = 0; ?>
<div class="row">
	<div class="col-md-12">
		<div class="box box-primary">
            <div class="box-header">
                <h1>Tìm kiếm với từ khóa: <?php echo $q; ?></h1>
            </div><!-- /.box-header -->
            <div class ="left">
			<h2>Đối tác</h2>
			  <div class="list-group">
			    <?php if (count($doitac)== 0): ?>
					<a href="#" class="list-group-item">
				      Không thấy đối tác
				    </a>    	
			    <?php else: ?>
			    	<?php foreach ($doitac as $value): ?>
			    		<?php $class = $count % 2 == 0 ? "active" : ""; $count++; ?>
				    	<a href="<?php echo Yii::app()->createUrl('/DoiTac/default/view',array('id'=>$value->id)); ?>" class="list-group-item <?php echo $class; ?>">
					    	<h4 class="list-group-item-heading"><?php echo $value->ten; ?></h4>
	        				<p class="list-group-item-text">
	        					Mã số: <?php echo $value->ma_so; ?>
	        				</p>
					    </a>
				    <?php endforeach ?>
				<?php endif; ?>
			  </div>
		</div>
	  	<div class="left">
	  		<h2>Khách hàng</h2>
			  <div class="list-group">
			    <?php if (count($khachhang)== 0): ?>
					<a href="#" class="list-group-item">
				      Không thấy khach hang
				    </a>    	
			    <?php else: ?>
			    	<?php foreach ($khachhang as $value): ?>
			    		<?php $class = $count % 2 == 0 ? "active" : ""; $count++; ?>
				    	<a href="<?php echo Yii::app()->createUrl('/KhachHang/default/view',array('id'=>$value->id)); ?>" class="list-group-item <?php echo $class; ?>">
					      <h4 class="list-group-item-heading"><?php echo $value->ten; ?></h4>
	        				<p class="list-group-item-text">
	        					Mã số: <?php echo $value->ma_so; ?>
	        				</p>
					    </a>
				    <?php endforeach ?>
				<?php endif; ?>
			  </div>
	  	</div>
	  	<div style="clear:both;"></div>
	  	<?php
	  	if ($data->totalItemCount > 0) {
	  	 $this->widget('ext.GLGridView', array(
            'id'=>'doitac-grid1',
            'cssFile' => Yii::app()->theme->baseUrl . '/css/gridView.css',
            'dataProvider'=>$data,
            'columns'=>array(
                array(
                    'name'=>'id',
                    'type'=> 'raw',
                    'value'=> 'CHtml::hiddenField("id", $data->id,array("class"=>"idhoadon")).$data->id', 
                ),
                array(
                    'name'=>'id_khachhang',
                    'htmlOptions'=>array('class'=>'name-ten'),
                    'value'=> '$data->khachhang == null ? "Không có" : $data->khachhang->ten',
                ),
                array(
                    'name'=>'id_doitac',
                    'htmlOptions'=>array('class'=>'name-ten'),
                    'value'=> '$data->doitac == null ? "Không có" : $data->doitac->ten',
                ),
                array(
                        'name'=>'ms_khachhang',
                        'htmlOptions'=>array('class'=>'ma-khachhang'),
                ),
                array(
                        'name'=>'ma_so_doi_tac',
                        'value'=>'$data->doitac == null ? "Không có" : $data->doitac->ma_so',
                        'htmlOptions'=>array('class'=>'ma-doitac'),
                    ),
                'so_phieu_thanh_toan',
                array(
                    'name'=>'so_tien',
                    'value'=>'getMoney($data->so_tien)'
                ),
                array(
                    'name'=>'chiet_khau',
                    'value'=>'getMoney($data->chiet_khau)'
                ),
                'ngay_su_dung',
                array(
                    'name'=>'Thanh toán với đối tác',
                    'type'=>'raw',
                    'value'=> 'CHtml::image("images/trangthai-{$data->trangthai_thanhtoan_dt}.png", "DORE",array("class"=>"image"));', 
                ),
                array(
                    'name'=>'Thanh toán với khách hàng',
                    'type'=>'raw',
                    'value'=> 'CHtml::image("images/trangthai-{$data->trangthai_thanhtoan_kh}.png", "DORE",array("class"=>"image"));', 
                ),
            ),
        ));
    } ?>
		</div>
	</div>
</div><!-- form -->
<script type="text/javascript">
$(document).on('keyup keypress', '#loai_hinh_kinhdoanh-tokenfield', function(e) {
  if(e.which == 13) {
    e.preventDefault();
    return false;
  }
});
</script>
<style type="text/css">
	.left{
		float: left;
		width: 32%;
		margin-left: 15px;
	}
</style>